package cn.edu.zjut.service;

import cn.edu.zjut.dao.ItemDAO;

import java.util.ArrayList;
import java.util.List;

/**
 * @author XiaoFeng
 * @version 1.0
 * @Description Create by 2021/10/27 19:08
 */

public class ItemService {
    private List items = new ArrayList<>();

    public List findByHql() {
        ItemDAO dao = new ItemDAO();
//        String hql = "from cn.edu.zjut.po.Item";
//        String hql = "from Item";
        String hql = "from Item as item";
//        String hql = "select item.ipk.title from Item as item";
//        使用 select 子句查询商品名称和商品价格
//        String hql = "select item.ipk.title,item.cost from Item as item order by item.cost desc";
//        where 子句
//        String hql = " select item.ipk.title,item.cost from Item as item where item.ipk.title='JAVAEE技术'";
        //聚集函数
//        String hql="select item.ipk.title,item.cost from Item as item group by item.ipk.title";
        List list = dao.findByHql(hql);
        dao.getSession().close();
        return list;
    }
}
